#  This file is part of the IVL Library (LIBIVL).
#
#  LIBIVL - library for interval computations 
#
#  Copyright (c) 2007 Mateusz Paprocki
#
#  The IVL Library is free software; you can redistribute it and/or modify
#  it under the terms of the GNU Lesser General Public License as published
#  by the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.
#
#  The IVL Library is distributed in the hope that it will be useful, but
#  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
#  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
#  License for more details.
#
#  You should have received a copy of the GNU Lesser General Public License
#  along with the IVL Library; see the file LICENCE.  If not, write to
#  the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
#  Boston, MA 02110-1301, USA.

SOURCES=ivl_base.c ivl_add.c ivl_sub.c ivl_mul.c ivl_div.c    \
        ivl_pow.c ivl_cmp.c ivl_set.c ivl_make.c ivl_expand.c \
        ivl_sets.c ivl_funcs.c ivl_trig.c ivl_hyper.c ivl_const.c

NAME=libivl

SONAME=$(NAME).so.0
LIBNAME=$(NAME).so
ARCHNAME=$(NAME).a

PY=python
CC=gcc
AR=ar
RM=rm

CCFLAGS=-Wall -g -DDEBUG
LDFLAGS=-shared -Wl,-soname,$(SONAME)
ARFLAGS=rcs

LIBS=-lmpfr

all: static dynamic pyivl

static: $(SOURCES:.c=.o)
	$(AR) $(ARFLAGS) $(ARCHNAME) $^
	
dynamic: $(SOURCES:.c=.lo)
	$(CC) $(LDFLAGS) $(LIBS) -o $(LIBNAME) $^
	
pyivl: pyivl.c pyivl.h
	$(PY) setup.py build

ivl_%.o : ivl_%.c interval.h
	$(CC) -c $(CCFLAGS) -o $@ $<

ivl_%.lo : ivl_%.c interval.h
	$(CC) -c -fPIC $(CCFLAGS) -o $@ $<

.PHONY: clean deep

clean:
	$(RM) -f *~ *.o *.lo
	
deep: clean
	$(RM) -f *.a *.so
	$(RM) -R -f build/
